package com.qianyu.project.web.controller.sy;

import com.qianyu.project.service.IProgressPaymentService;
import com.qianyu.project.utils.Result;
import com.qianyu.project.utils.ResultTool;
import com.qianyu.project.vo.ProgressPaymentExtend;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("apply")
public class ProgressPaymentController {
    @Autowired
    private IProgressPaymentService progressPaymentService;

    @GetMapping("getMaxId")
    public Result getMaxId(){
        return ResultTool.success(Long.parseLong(progressPaymentService.getMaxId()) + 1);
    }

    @PostMapping
    public Result save(@RequestBody ProgressPaymentExtend progressPaymentExtend){
        progressPaymentService.saveBoth(progressPaymentExtend.getApplyForm(), progressPaymentExtend.getApplyDetails());
        return ResultTool.success();
    }

    @GetMapping
    public Result getList(@RequestParam Map<String, String> params){
        return ResultTool.success(progressPaymentService.getList(params));
    }

    /**
     * 用id查询单个数据
     * @param id
     * @return
     */
    @GetMapping("{id}")
    public Result selectOne(@PathVariable String id){
        return ResultTool.success(progressPaymentService.selectOne(id));
    }

    /**
     * 进度款申报查询
     * @param params
     * @return
     */
    @GetMapping("query")
    public Result getProgressQuery(@RequestParam Map<String, String> params){
        return ResultTool.success(progressPaymentService.getProgressQuery(params));
    }

}
